<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head></h:head> 
  
    <f:view>
               <h:form id="UserForm" prependId="false" >
                   <p:growl id="growl" showDetail="true" life="3000" /> 
                         <p:panel header="Thêm Mới Môn Học" style="background-color: #ebf3fd;">  
                            <h:panelGrid columns="2" cellpadding="5">  
                                         <h:outputLabel for="username" value=" Mã Môn Học : *" />  
                                         <p:inputText value="#{monhocbean.mamh}"   id="username" required="true" label="username" />  
                                         <h:outputLabel for="tenmh" value="Tên Môn Học : * " />  
                                         <p:inputText value="#{monhocbean.tenmh}"   id="tenmh" required="true" label="Tên Môn Học" />  
                                         <h:outputLabel for="ghiChu" value=" Ghi Chú :  " />  
                                         <p:inputTextarea    value="#{monhocbean.ghiChu}"   id="ghiChu" required="true" label="Ghi Chú " /> 
                                     <f:facet name="footer">  
                                         <p:commandButton value=" Thêm Mới " update="formTable,UserForm"    actionListener="#{monhocBO.add(monhocbean)}" ajax="true"  />               
                                     </f:facet>  
                           </h:panelGrid> 
                       </p:panel> 
                             <p:dataTable var="mh" value="#{monhocBO.listAllMonHoc()}" id="list"  selectionMode="single"  paginator="true" rows="10"  
                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                 rowsPerPageTemplate="5,10,15" >
   
                                   <f:facet name="header"  >
                                           Môn Học 
                                      </f:facet>

                                      <p:column headerText=" Mã Môn Học" style="width:150px">
                                                <h:outputText value="#{mh.mamh}" />
                                        </p:column>
                                        <p:column headerText="Tên Môn Học" style="width:150px">     
                                                    <h:outputText value="#{mh.tenmh}" />
                                        </p:column>
                                        <p:column headerText="Ghi Chú" style="width:150px">  
                                                    <h:outputText value="#{mh.ghiChu}" />
                                        </p:column>
     
                                        <p:column headerText="Action">
                                            <p:commandButton value ="Xóa" actionListener="#{monhocBO.delete(mh)}" update="formTable" ajax="true"/>
                                        </p:column>
          
          </p:dataTable>
   </h:form>

</f:view>
     
  
</html>

